package com.frank.activedatabus.broadcast;

import com.frank.activedatabus.Core.LiveEventBusCore;
import ohos.aafwk.content.Intent;
import ohos.event.commonevent.CommonEventData;
import ohos.event.commonevent.CommonEventSubscribeInfo;

/**
 * @version 1.0.1
 * @description:公共事件接收
 * @program: activedatatest
 * @Author xiaozhijun
 * @Date 2020/12/23 10:32
 */
public class BroadCastEventSubscriber extends ohos.event.commonevent.CommonEventSubscriber {

    private static final String TAG = "CommonEventSubscriber";

    public BroadCastEventSubscriber(CommonEventSubscribeInfo subscribeInfo) {
        super(subscribeInfo);
    }

    @Override
    public void onReceiveEvent(CommonEventData commonEventData) {
        Intent intent = commonEventData.getIntent();
        if (intent != null) {
            String action = intent.getAction();
            LiveEventBusCore.get().getChannel(action).post(commonEventData);
        }
    }
}
